// C++ author 清晨与猫鱼
#include <iostream>
#include <string>
#include <memory>
#include "Realize.h"

using namespace std;

/*
\ brief:  打印函数
\ author: 清晨与猫鱼
*/
void printPersons(unique_ptr<list<Person>> persons) {
    for (Person& person : *persons) {
        cout << person.getName() << "   "
        << person.getGender() << "   "
        << person.getMaritalStatus() << endl;
    }
}


int main(const int argc, const char** argv)
{	
    
    // 人类列表
	list<Person> persons;

    // 添加元素
    persons.emplace_back("Robert","Male", "Single");
    persons.emplace_back("John","Male", "Married");
    persons.emplace_back("Laura","Female", "Married");
    persons.emplace_back("Diana","Female", "Single");
    persons.emplace_back("Mike","Male", "Single");
    persons.emplace_back("Bobby","Male", "Single");


    // 男性过滤
    CriteriaMale male;

    // 女性过滤
    CriteriaFemale female;

    // 满足两种条件的
    AndCriteria singleMale(new CriteriaSingle, new CriteriaMale);

    // 满足其中一种条件的
    OrCriteria singleOrFemale(new CriteriaSingle, new CriteriaFemale);

    // 下面的打印结果
    cout << "------------------" << endl;
    unique_ptr<list<Person>> datas(male.meetCriteria(persons));
    printPersons(move(datas));

    cout << "------------------" << endl;

    datas.reset(female.meetCriteria(persons));
    printPersons(move(datas));

    cout << "------------------" << endl;
    datas.reset(singleMale.meetCriteria(persons));
    printPersons(move(datas));

    cout << "------------------" << endl;
    datas.reset(singleOrFemale.meetCriteria(persons));
    printPersons(move(datas));

    
}